<template>
  <div>
    <s-nav-bar :title="title"></s-nav-bar>
    <my-skeleton v-if="initLoading"></my-skeleton>
    <template v-else>
      <book-list :data="datalist"></book-list>
    </template>
  </div>
</template>

<script>
import sNavBar from '@/components/sNavBar.vue'
import BookList from '@/components/BookList.vue'
import MySkeleton from '@/components/MySkeleton.vue'
export default {
  components:{
    sNavBar,
    BookList,
    MySkeleton
  },
  data(){
    return {
      initLoading:true,
      title:'',
      datalist:[]
    }
  },
  created(){
    //获取数据
    this.$http.get(this.$route.meta.dataURL,{
      params:{
        id:this.$route.params.id
      }
    })
    .then(res => {
      let {kind,datalist} = res.data.data
      if(!kind){
        return this.$router.replace('/404')
      }
      
      //设置title
      document.title = kind + ' - 喜阅分类'
      this.title = kind
      this.datalist = datalist
      setTimeout(()=>{
        this.initLoading = false
      },1000)
       
      
    })
    .catch(err => {
      throw ('NET ERROE!')
    })
  }
}
</script>

<style>

</style>